﻿using Tszy.Unlimited.Base.BackgroundTasks;
using Tszy.Unlimited.Base.Exceptions;
using Tszy.Unlimited.Data.FreeSQL;

namespace Tszy.Workers.Workers;

public class TestWorker1 : ScopedBackgroundServiceBase
{
    private readonly FreeSqlDbContext _context;

    public TestWorker1(FreeSqlDbContext context)
    {
        _context = context;
    }

    public override Task DoWorkAsync(CancellationToken stoppingToken)
    {
        throw new MainApplicationException("退出！");
    }

    protected override async Task OnDoWorkAsync(CancellationToken stoppingToken)
    {
        Console.WriteLine($"{Name}[{_context.UniqueId}] working!");
        await Task.CompletedTask;
    }
}